//
//  FZQMarkViewController.m
//  BiliBiliDemo
//
//  Created by IMAC on 16/4/17.
//  Copyright © 2016年 XDH. All rights reserved.
//

#import "FZQMarkViewController.h"

@implementation FZQMarkViewController

#pragma mark - life cycle

- (void)viewDidLoad {
    [super viewDidLoad];
    

}

//#import "ViewController.h"
//
//@interface ViewController ()<UIScrollViewDelegate>
//
///**
// *  scrollView
// */
//@property (weak, nonatomic) UIScrollView *scView;
///**
// *  curView
// */
//@property (weak, nonatomic) UIView *curView;
///**
// *  reuseView
// */
//@property (weak, nonatomic) UIView *reuserView;
//
///**
// *
// */
//@property (strong, nonatomic) NSMutableArray <UIView *> *views;
//@end
//
//#define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width
//#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height
//
//@implementation ViewController
//- (NSMutableArray *)views
//{
//    if (_views == nil) {
//        _views = [NSMutableArray array];
//    }
//    return _views;
//}
//
//- (void)viewDidLoad {
//    [super viewDidLoad];
//    
//    
//    [self setupScrollView];
//    
//    [self setupViews];
//    
//    [self addViewsToScrollView];
//}
//
//
////添加一个scrollView
//- (void)setupScrollView
//{
//    UIScrollView *scV = [[UIScrollView alloc] init];
//    scV.frame = self.view.bounds;
//    [self.view addSubview:scV];
//    scV.pagingEnabled = YES;
//    //    scV.directionalLockEnabled = YES;
//    scV.delegate = self;
//    scV.contentSize = CGSizeMake(3 * SCREEN_WIDTH, 0);
//    
//    self.scView = scV;
//}
//
////添加两个View到ScrollView
//- (void)addViewsToScrollView
//{
//    //循环利用view
//    UIView *v1 = self.views[0];
//    v1.frame = self.view.frame;
//    //    UIImageView *imgV1 = [[UIImageView alloc] initWithFrame:v1.bounds];
//    //    [v1 addSubview:imgV1];
//    [self.scView addSubview:v1];
//    self.reuserView = v1;
//    
//    
//    
//    //显示的view
//    UIView *v2 = self.views[1];
//    v2.frame = CGRectMake(SCREEN_WIDTH, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
//    //    UIImageView *imgV2 = [[UIImageView alloc] initWithFrame:v2.bounds];
//    //    imgV2.image = [UIImage imageNamed:@"01"];
//    //    [v2 addSubview:imgV2];
//    [self.scView addSubview:v2];
//    self.curView = v2;
//    self.scView.contentOffset = CGPointMake(SCREEN_WIDTH, 0);
//    
//    
//}
//
////-(void)viewWillAppear:(BOOL)animated
////{
////    [super viewWillAppear:animated];
////    
////    //初始化开始需要显示的view
////    if (self.views.count > 2) {
////        
////        [self.reuserView addSubview:self.views[0]];
////        [self.curView addSubview:self.views[1]];
////        NSLog(@"%@",self.views);
////    }
////}
//
////初始化view
//- (void)setupViews
//{
//    UIView *view1 = [UIView new];
//    view1.frame = self.scView.frame;
//    view1.backgroundColor = [UIColor redColor];
//    [self.views addObject:view1];
//    
//    UIView *view2 = [UIView new];
//    view2.frame = self.scView.frame;
//    view2.backgroundColor = [UIColor greenColor];
//    [self.views addObject:view2];
//    
//    UIView *view3 = [UIView new];
//    view3.frame = self.scView.frame;
//    view3.backgroundColor = [UIColor blueColor];
//    [self.views addObject:view3];
//    
//    UIView *view4 = [UIView new];
//    view4.frame = self.scView.frame;
//    view4.backgroundColor = [UIColor whiteColor];
//    [self.views addObject:view4];
//}
//
//#pragma mark - ScrollViewDelegate
//- (void)scrollViewDidScroll:(UIScrollView *)scrollView
//{
//    NSInteger index = [self.views indexOfObject:self.curView];
//    
//    CGRect frame = CGRectZero;
//    //判断拖动的方向
//    if (scrollView.contentOffset.x > SCREEN_WIDTH) {//右移
//        
//        //将reView添加到curView的右边
//        frame = CGRectMake(2 * SCREEN_WIDTH, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
//        index += 1;
//        if (index > self.views.count - 1) {
//            index = 0;
//        }
//    } else {//左移
//        
//        //将reView添加到curView的左边
//        frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
//        index -= 1;
//        if (index < 0) {
//            index = self.views.count - 1;
//        }
//    }
//    
//    if ([self.views indexOfObject:self.reuserView] != index || self.reuserView.tag != MAXFLOAT) {
//        
//        //移除旧控件
//        [self.reuserView removeFromSuperview];
//        
//        //加载reuseView的数据
//        self.reuserView = self.views[index];
//        self.reuserView.frame = frame;
//        
//        // 重新添加控件
//        [self.scView addSubview:self.reuserView];
//        
//        //设置tag值
//        self.reuserView.tag = MAXFLOAT;
//    }
//    ///////////////////////////////////////////////////////////////////////////////
//    //        UIImageView *imgV = self.reuserView.subviews[0];
//    //        imgV.image = [UIImage imageNamed:[NSString stringWithFormat:@"0%zd", index]];
//    ///////////////////////////////////////////////////////////////////////////////
//    
//    //    当移动距离 >= 屏幕宽度时 \
//    //    (如果用"=="的bug: 手速太快有可能会超过屏幕宽度导致不进入判断)
//    if (scrollView.contentOffset.x <= 0 || scrollView.contentOffset.x >= 2 * SCREEN_WIDTH) {
//        //1.交换指向reuseView和curView的指针
//        UIView *tempV = self.curView;
//        self.curView = self.reuserView;
//        self.reuserView = tempV;
//        
//        //2.交换reuseView和curView的位置
//        CGRect frame = self.curView.frame;
//        self.curView.frame = self.reuserView.frame;
//        self.reuserView.frame = frame;
//        
//        //3.scrollView显示curView
//        self.scView.contentOffset = CGPointMake(SCREEN_WIDTH, 0);
//        
//        //4.重新添加控件:如果不移除再添加，不会刷下view的信息
//        [self.curView removeFromSuperview];
//        [self.reuserView removeFromSuperview];
//        [self.scView addSubview:self.curView];
//        [self.scView addSubview:self.reuserView];
//        
//        //5.重置reuseView tag值
//        self.reuserView.tag = 0;
//    }
//    
//    
//}
//
//
//@end
@end
